﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using System.Xml.Linq;
using Shiny.SmartTravel.Data.Local;
using Shiny.SmartTravel.Data.Local.MyTravel;

namespace Shiny.SmartTravel
{
    /// <summary>
    /// Interaction logic for ConsoleWindow.xaml
    /// </summary>
    public partial class ConsoleWindow : Window
    {
        public ConsoleWindow()
        {
            try
            {
                InitializeComponent();

                this.ContentFrame.Navigate(new Uri("EarthPage.xaml", UriKind.Relative));
            }
            catch (Exception ex)
            {
                MessageBox.Show("So sorry for SmartTravel was not working correctly for you.\nSmartTravel will exit after you click the button.\n\n" + ex.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                App.Current.Shutdown();
            }
        }

        /// <summary>
        /// OnPreview key down,process the key events.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void OnPreviewKeyDown(object sender, KeyEventArgs e)
        {
            if (e.Key == Key.Escape)
            {
                ConfirmShutdown();
            }
        }

        /// <summary>
        /// Promote user when shutdown
        /// </summary>
        private static void ConfirmShutdown()
        {
            if (MessageBox.Show("Exit SmartTravel now?\n\nPlease don't forget drop me a comment on http://codeplex.com/SmartTravel, greak thanks.", "Please Confirm Exit", MessageBoxButton.YesNo, MessageBoxImage.Question, MessageBoxResult.No) == MessageBoxResult.Yes)
            {
                App.Current.Shutdown();
            }
        }

        private void btnTopClose_Click(object sender, RoutedEventArgs e)
        {
            ConfirmShutdown();
        }

        private void mFileAccount_Click(object sender, RoutedEventArgs e)
        {

        }

        private void mFileExit_Click(object sender, RoutedEventArgs e)
        {
            ConfirmShutdown();
        }

        private void mHelpContent_Click(object sender, RoutedEventArgs e)
        {
            HelpContentWindow hc = new HelpContentWindow();
            hc.ShowDialog();
        }

        private void mHelpAbout_Click(object sender, RoutedEventArgs e)
        {
            AboutWindow aw = new AboutWindow();
            aw.ShowDialog();
        }



        protected void ControlPanel_MouseLeave(object sender, MouseEventArgs e)
        {
        }

        protected void ControlPanel_Closed(object sender, EventArgs e)
        {
            ControlPanel.SelectedIndex = 0;
        }
    }
}
